package com.example.ispy;

import android.media.MediaPlayer;
import android.os.Bundle;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.view.Menu;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;
import android.widget.TextView;

public class StartPage extends Activity {
	
	MediaPlayer mp;

	@TargetApi(16)
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start_page);
        
        TextView txt = (TextView) findViewById(R.id.title_page);
        Typeface font = Typeface.createFromAsset(getAssets(), "eyes.ttf");  
        txt.setTypeface(font);
        
        LinearLayout titleboard = (LinearLayout) findViewById(R.id.title_board);
        titleboard.setBackground(Sd(Color.WHITE));
        titleboard.getBackground().setAlpha(210);
    }
    
    @Override
    public void onStart(){
    	super.onStart();
		mp = MediaPlayer.create(this,R.raw.happyboy);
		mp.seekTo(500);
		mp.start();    	
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_start_page, menu);
        return true;
    }
    
    @Override
    public void onStop(){
    	super.onStop();
    	mp.release();
    	mp = null;    	
    }
    
    public void start(View view){
    	view.startAnimation(AnimationUtils.loadAnimation(this, R.anim.icon_click));
    	Intent intent = new Intent(this, MainActivity.class);
    	intent.putExtra("pageNo", 1);
    	startActivity(intent);
    }
    
    public ShapeDrawable Sd(int s){

    	float[] outerR = new float[] { 12, 12, 12, 12, 12, 12, 12, 12 };
    	ShapeDrawable mDrawable = new ShapeDrawable(new RoundRectShape(outerR, null,null));

    	            mDrawable.getPaint().setColor(s);
    	return mDrawable;
    	}
    
    public void exit(View view) {
    	finish();
    }
}
